<script setup>
  import Layout from '@/components/Layout.vue'
  import userRoutes from '@/router/user'
  import { useUserStore } from '@/store'
  import { computed } from 'vue'

  // 移除不需要的路由
  const routes = computed(() => {
    const userStore = useUserStore()
    const routes = userRoutes.children.filter(route => route.meta.role.includes(userStore.role) && !route.meta.hide)
    return {
      ...userRoutes,
      children: routes,
    }
  })
</script>

<template>
  <Layout :routes="routes">
    <router-view></router-view>
  </Layout>
</template>
